package com.java.oop;

/**
 * 学生类
 */
public class Student {

    //姓名属性
    private String name;
    //年龄属性
    private int age;
    //性别属性
    private String gender;

    public Student() {
    }

    public Student(String name, int age, String gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if(age >= 18 && age <= 40){
            this.age = age;
        }else{
            System.out.println("您的年龄不符合学生要求");
        }
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }


    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                '}';
    }

    /**
     * 打招呼方法
     */
    public void sayHi(){
        System.out.println("Hi!!我是" + name +",年龄：" + age +",性别是：" + gender);
    }
}
